< previous page page_103 next page >

Page 103
netapi32.1ib. Now, the import library name is not always the same as the DLL name, so I took a quick look at the system32 directory on my NT system. Sure enough, there is a DLL named netapi32.dll. I was still not absolutely sure that this was the correct DLL, but it's a very good guess. The declaration is as follows:
Private Declare Function NetUserAdd Lib "netapi32.dll" ( _
    ByVal servername As Long, ByVal level As Long, _
    ByVal buf As Long, parm_err As Long) As Long
Why did I make these choices?
The servername parameter is a Long. If I defined it as a string, Visual Basic would convert the string to ANSI, and this needs to be a Unicode string. By specifying it ByVal As Long, I can pass an explicit address to a Unicode string. The level parameter is obviously a Long. For the buf parameter, I had several choices: I could declare it to be one of the structure types, declare it to be As Any, or use a Long again and pass the address of the structure. I chose the latter. The parm_err parameter is also a Long, but this time passed by reference because the parameter is an LPDWORDa pointer to a 32-bit variable.
The Structure
Since the original question referred only to the USER_LEVEL_2 structure, I just dealt with that particular structure. The C declaration for the structure is as follows:
typedef struct _USER_INFO_2 {
    LPWSTR   usri2_name;
    LPWSTR   usri2_password;
    DWORD    usri2_password_age;
    DWORD    usri2_priv;
    LPWSTR   usri2_home_dir;
    LPWSTR   usri2_comment;
    DWORD    usri2_flags;
    LPWSTR   usri2_script_path;
    DWORD    usri2_auth_flags;
    LPWSTR   usri2_full_name;
    LPWSTR   usri2_usr_comment;
    LPWSTR   usri2_parms;
    LPWSTR   usri2_workstations;
    DWORD    usri2_last_logon;
    DWORD    usri2_last_logoff;
    DWORD    usri2_acct_expires;
    DWORD    usri2_max_storage;

 
< previous page page_103 next page >